package cn.steel.controller.manager;

import cn.steel.domain.entity.EmailLog;
import cn.steel.service.EmailLogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Slf4j
@Controller
@RequestMapping("/manager/email")
@RequiredArgsConstructor
public class EmailController {

    private final EmailLogService emailLogService;

    @GetMapping("/log")
    public String emailLogPage(Model model) {
        List<EmailLog> emailLogs = emailLogService.getAllEmailLogs();
        model.addAttribute("emailLogs", emailLogs);
        log.info("Loaded email log page, log count={}", emailLogs.size());
        return "manager/email_log";
    }
}